package com.msnjob.base;


import java.util.List;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import base.action.lib.BaseAction;
import base.db.lib.DBHelper;
import base.db.lib.util.ConncenFactory;
@SuppressWarnings("all")
public class CityAction extends BaseAction implements java.io.Serializable{
	/**
	 * 获取城市级联数据
	 * Register.asp
	 * @return
	 * @throws Exception
	 */
	public String getCityCodeByType() throws Exception {
		HttpServletRequest request = ServletActionContext.getRequest();
		String type=request.getParameter("type");
		StringBuffer sql=new StringBuffer(" select webid ,city,oneid,twoid,threeid from china_city ");
		Vector params = new Vector();
		sql.append(" where 1=1 ");
		if("sheng".equals(type)){
			//获取省份数据
		 sql.append(" and twoid=? ");
		 params.add("0");
		}else if("city".equals(type)){
			//根据省的code 获取城市信息
			String procode=request.getParameter("procode");
			 sql.append(" and oneid=?  and  threeid=? and twoid !=? ");
			 params.add(procode);
			 params.add("0");
			 params.add("0");
			//oneid=20 and  threeid=0 and twoid !=0
		}else if("quyu".equals(type)){
			//某某城市获取 区域信息
//			select webid ,city,oneid,twoid,threeid from china_city
//			where oneid=20 and  twoid=26  and threeid !=0 
			String procode=request.getParameter("procode");
			String citycode=request.getParameter("citycode");
			sql.append("  and oneid=? and twoid=? and  threeid !=?  ");
			params.add(procode);
			params.add(citycode);
			params.add("0");
			
		}else{
			//获取省份数据
			 sql.append(" twoid=? ");
			 params.add("0");
		}
		
		 sql.append(" order by oneid ");
		 List  list=DBHelper.list(sql.toString(), params);
		ConncenFactory.colseConnection();
		 this.setAjaxList(list);
	
		 return "ajax";
	}
	
}
